<?php
class User extends AppModel{
	public $name='User';
	
	public $validate = array(
		'username' => 'notEmpty',
		'email' => 'email',
	);
	
	public $belongsTo = array('Group');
	public $actsAs = array('Acl' => array('type' => 'requester'));
	
	 
	public function parentNode() {
        if (!$this->id && empty($this->data)) {
            return null;
        }
        if (isset($this->data['User']['group_id'])) {
            $groupId = $this->data['User']['group_id'];
        } else {
            $groupId = $this->field('group_id');
        }
        if (!$groupId) {
            return null;
        } else {
            return array('Group' => array('id' => $groupId));
        }
    }
    
    public function bindNode($user) {
    	return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']);
	}
    
	public function getUserByArrayUserId($arrUserId,$arrNot=null){
		$conditions['Not']['User.group_id']=array(1,4);
		
		if(is_array($arrUserId) || intval($arrUserId)>0)$conditions['User.id']=$arrUserId;
		if(is_array($arrNot) || intval($arrNot)>0)$conditions['Not']['User.id']=$arrNot;
		return $this->find('all',array('conditions'=>$conditions));
	}
	
	
		
}
?>
